package com.ruoyi.project.platform.agent.basic;

import com.alibaba.fastjson.annotation.JSONField;
import com.ruoyi.project.platform.agent.constant.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class AccountDto {

    @Data
    public static class Exchange {
        private String platform;//": "mxc",
        private String tagName;//": "depth_mx",
        private String sequence;//": "1",
        private String secretKey;//": "60020f99031e49cdbbb15e48484d0908",
        private String passphrase;//": "",
        private String apiKey;//": "mx0OsSFkSUPSztImTB",
        private String description;//": "13311758176D",
        private String tickSize;//": "0.001",
        private String sizeIncrement;//": "0.0001",
        private String quoteCurrency;//": "USDT",
        private String baseCurrency;//": "MDU",
        private String minSize;//": "5",
        private String name;//": "MDU_USDT"
    }

    @Data
    public static class AccountTotal {
        private Double quoteTotal;
        private Double baseTotal;
        private String dayStr;
    }

    @Data
    public static class BalanceItem {
        private Platform platform;
        private Double initMdu;
        private Double initUsdt;
        private Double totalMdu;
        private Double totalUsdt;
        private Double availableMdu;
        private Double availableUsdt;
        private String platformName;
        private String info;
    }

    @Data
    public static class OrderItem {
        private String symbol;//string	交易对名称
        private String id;//string	订单id
        private String price;//string	挂单价格
        private String quantity;//string	挂单数量
        private String dealQuantity;//string	成交数量
        private String dealAmount;//string	成交金额
        private Long createTime;//string	下单时间
        private OrderState state;//string	订单状态
        private OrderType type;//string	订单类型
        private String clientOrderId;//string	客户订单id
        private DealType dealType;

        public String notDealQuality() {
            return (Double.parseDouble(getQuantity()) - Double.parseDouble(getDealQuantity())) + "";
        }
    }

    @Data
    public static class PlatformCacls {
        private Double usdtTotal;
        private Double usdtAvailable;
        private Double usdtFrozen;
        private Double mduTotal;
        private Double mduAvailable;
        private Double mduFrozen;
        private String accessKey;
        private String secretKey;
        private String info;
        private Double initMdu;
        private Double initUsdt;
        private Platform platform = Platform.mxc;
    }

    @Data
    public static class Depth {
        private Double price;
        private Double quality;
    }

    @Data
    public static class DepthWrapper {
        private List<Depth> asks;
        private List<Depth> bids;

        public static DepthWrapper DEFAULT_WRAPPER = new DepthWrapper();

        static {
            DEFAULT_WRAPPER.setAsks(new ArrayList<>());
            DEFAULT_WRAPPER.setBids(new ArrayList<>());
        }
    }

    @Data
    public static class KlineItem {
        private Long time;//	开始时间 (以秒表示的10位时间戳)
        private Double open;//	开盘价
        private Double close;//	收盘价
        private Double high;//	最高价
        private Double low;//	最低价
        private Double vol;//	成交量
        private Double amount;//	计价货币成交
    }

    @Data
    public static class OrderDepth {
        List<Object> prices = new ArrayList<>();//从小到大
        List<Object> bidsDepth = new ArrayList<>();
        List<Object> asksDepth = new ArrayList<>();
        List<Object> bidOrders = new ArrayList<>();
        List<Object> askOrders = new ArrayList<>();

        List<Object> bidDelta = new ArrayList<>();//散户累积量
        List<Object> askDelta = new ArrayList<>();//散户累积量
        List<Object> bidDeltaValue = new ArrayList<>();//散户累积价值
        List<Object> askDeltaValue = new ArrayList<>();//散会累积价值

        Double safeBid;//安全买单
        Double safeAsk;//安全卖单
    }

    @Data
    public static class SafeRange {
        Double safeBid = -1d;//安全买单
        Double safeAsk = -1d;//安全卖单
        String direction;
        Long ts = System.currentTimeMillis() / 1000;
    }

    @Data
    @ApiModel
    public static class SafeOrder {
        @ApiModelProperty
        String sn;
        @ApiModelProperty
        Double price;
        @ApiModelProperty
        Double mount;
        @ApiModelProperty
        String type;//bid ask
        @ApiModelProperty
        String ts;
        @ApiModelProperty
        String direction;
    }


    @Data
    public static class UsdtInfo {
        List<Double> totalInfo = new ArrayList<>();
        List<Double> klineInfo = new ArrayList<>();
        List<Double> depthInfo = new ArrayList<>();
        List<Long> timeStr = new ArrayList<>();
    }

    @Data
    public static class AvgPrice {
        Double avgPrice;
        Long timeStr;
        Double deltaMdu;
        Double deltaUsdt;
    }

    @Data
    public static class ODPair {
        String depthMount = "";
        String orderMount = "";
        DealType type;
        Double price;
        Double accOrderMount = 0d;
        Double accDepthMount = 0d;
        Double accDeltaMount = 0d;
        Double accDeltaMountValue = 0d;
    }

    @Data
    public static class JsonConfig {
        @JSONField(name = "json_path")
        String jsonPath;
        List<Double> low = new ArrayList<>();
        List<Double> per = Arrays.asList(0.02);
        List<Object> praras = new ArrayList<>();
        Integer interval = 10;


        public JsonConfig cfg(String jsonPath, Integer direction, Double endPrice, Integer minutes, Integer times) {
            this.jsonPath = jsonPath;
            this.praras.add(direction);
            this.praras.add(endPrice);
            this.praras.add(minutes);
            this.praras.add(times == null ? 3 : times);
            this.low.add(endPrice);
            return this;
        }

    }

    @Data
    public static class FixedAction {
        Double price;
        DealType dealType;
        Double quality;
        Platform platform;
        AccountType type;
    }

    @Data
    public static class Action {
        Double price;
        Integer direction;
        Platform platform;
        Integer lastMinutes;
    }

}
